/**
 *
 */
package org.cholm.drtest;

import java.util.ArrayList;
import java.util.List;

// import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author cholm
 *
 */
public class Serie  {
	/**
	 * Constructor
	 *
	 * @param json JSON data
	 *
	 * @throws Exception On error
	 */
	public Serie(JSONObject data0)
	{
		title            = data0.optString("Title");
		genre            = data0.optString("OnlineGenreText");
		url              = data0.optString("Url");
		slug             = data0.optString("ProgramSeriesSlug");
		channel          = data0.optString("ChannelSlug");
		img              = data0.optString("Image");
		if (slug != null && !slug.isEmpty()) {
			letter = Character.toString(slug.charAt(0));
			if (!Character.isLetter(letter.charAt(0))) letter = "-";
		}
	}
	/**
	 * Check if fields are set
	 *
	 * @return true if the fields are set
	 */
	public boolean isValid()
	{
		return !(letter  == null ||
				 genre   == null ||
				 slug    == null ||
				 channel == null ||
				 title   == null);
	}
	/** @return the title */
	public String getTitle() { return title; }
	/**  @return the slug */
	public String getSlug() { return slug; }
	/** @return the program url */
	public String getUrl() { return url; }
	/** @return the genre */
	public String getGenre() { return genre; }
	/** @return the channel */
	public String getChannel() { return channel; }
	/** @return Image url */
	public String getImage() { return img; }
	/** @return the videos */
	public List<Program> getVideos() { return videos; }
	/** @return the letter */
	public String getLetter() { return letter; }
	/** Our slug */
	protected String slug = null;
	/** Our title */
	protected String title = null;
	/** Presentation URL */
	protected String url = null;
	/** Genre */
	protected String genre = null;
	/** Channel */
	protected String channel = null;
	/** Image url */
	protected String img = null;
	/** First letter */
	protected String letter = null;
	/** List of videos */
	protected List<Program> videos = new ArrayList<Program>();
}
//
// EOF
//
